import 'package:flutter/material.dart';
import 'package:sainbainu/common/values/colors.dart';
import 'package:sainbainu/view/login/controller.dart';
import 'package:get/get.dart';
import 'widgets.dart';

class FindPwd extends GetView<LoginController> {
  final VoidCallback onSubmit;
  final VoidCallback onPwdLogin;
  final VoidCallback onCodeBtnPressed;

  const FindPwd({
    Key? key,
    required this.onSubmit,
    required this.onPwdLogin,
    required this.onCodeBtnPressed,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        const LoginTitle('找回密码'),
        const SizedBox(height: 50),
        CustomInput(
          hintText: '输入手机号',
          controller: controller.state.mobileController,
          keyboardType: TextInputType.phone,
        ),
        const SizedBox(height: 10),
        CustomInput(
          hintText: '输入验证码',
          keyboardType: TextInputType.number,
          suffixIcon: Padding(
            padding: const EdgeInsets.all(4),
            child: SizedBox(
              width: 90,
              child: Obx(
                () => ElevatedButton(
                  style: ElevatedButton.styleFrom(
                    backgroundColor: AppColors.danger,
                    foregroundColor: Colors.white,
                    padding: const EdgeInsets.all(0),
                    disabledForegroundColor: AppColors.unactive,
                  ),
                  onPressed: controller.state.isSending.value
                      ? null
                      : onCodeBtnPressed,
                  child: controller.state.isSending.value
                      ? Text('${controller.state.smsSeconds.value}s')
                      : Text('短信获取'.tr),
                ),
              ),
            ),
          ),
        ),
        const SizedBox(height: 50),
        LoginBtn(
          text: '确认找回',
          onPressed: onSubmit,
        ),
        const SizedBox(height: 20),
        LoginTextBtn(
          text: '密码登录',
          onPressed: onPwdLogin,
        ),
      ],
    );
  }
}
